#pragma once

extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
                               spinlock_t **ptl);
extern int __pte_alloc(struct mm_struct *mm, pmd_t *pmd);

static inline pte_t *get_locked_pte(struct mm_struct *mm, unsigned long addr,
                                    spinlock_t **ptl)
{
    pte_t *ptep;

    ptep = __get_locked_pte(mm, addr, ptl);

    return ptep;
}

static inline int insert_page_into_pte_locked(struct vm_area_struct *vma, pte_t *pte,
                                              unsigned long addr,
                                              struct page *page, pgprot_t prot)
{
    return 0;
}

#define pte_alloc(mm, pmd) (unlikely(pmd_none(*(pmd))) && __pte_alloc(mm, pmd))

#define pte_alloc_map_lock(mm, pmd, address, ptlp) \
    (pte_alloc(mm, pmd) ? NULL : pte_offset_map_lock(mm, pmd, address, ptlp))
